package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 报损记录
 * </p>
 *
 * @author dq
 * @date 2022-09-23
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "ServiceLossLossSourceEnum", description = "报损来源 #{IN_INVENTORY:入库报损;RETURN_SERVICE:归还报损-枚举")
public enum ServiceLossLossSourceEnum implements BaseEnum {

    /**
     * IN_INVENTORY="入库报损"
     */
    IN_INVENTORY("入库报损"),
    /**
     * RETURN_SERVICE="归还报损"
     */
    RETURN_SERVICE("归还报损"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static ServiceLossLossSourceEnum match(String val, ServiceLossLossSourceEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static ServiceLossLossSourceEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(ServiceLossLossSourceEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "IN_INVENTORY,RETURN_SERVICE", example = "IN_INVENTORY")
    public String getCode() {
        return this.name();
    }

}
